package com.cheng.spring04.dao.impl;

import com.cheng.spring04.dao.UserDao;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl implements UserDao {
    private final JdbcTemplate jdbcTemplate;

    public UserDaoImpl(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public void updateUserBalanceByUserId(int userId,int price) {
        String sql = "update t_user2 set balance = balance - ? where id = ?";
        jdbcTemplate.update(sql,price,userId);
    }


}
